package com.westos.echufang.utils;

import org.apache.commons.lang.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;


@Component
public class EmailUtil {

    private JavaMailSenderImpl mailSender;

    @Autowired
    public EmailUtil(JavaMailSenderImpl mailSender) {
        this.mailSender = mailSender;
    }

    @Async
    public void send(String email, String code) {
        SimpleMailMessage mailMessage = new SimpleMailMessage();
        mailMessage.setSubject("找回密码");
        mailMessage.setText("验证码为：" + code);
        mailMessage.setTo(email);
        mailMessage.setFrom("1434708196@qq.com");
        mailSender.send(mailMessage);
    }

    @Async
    public void send1(String email, String code) {
        SimpleMailMessage mailMessage = new SimpleMailMessage();
        mailMessage.setSubject("注册账户");
        mailMessage.setText("验证码为：" + code);
        mailMessage.setTo(email);
        mailMessage.setFrom("1434708196@qq.com");
        mailSender.send(mailMessage);
    }

}
